package com.yjha.lzmarathonsys.service.impl;

import com.yjha.lzmarathonsys.utils.R;
import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yjha.lzmarathonsys.utils.PageUtils;
import com.yjha.lzmarathonsys.utils.Query;

import com.yjha.lzmarathonsys.mapper.TbUserInfoMapper;
import com.yjha.lzmarathonsys.bean.TbUserInfo;
import com.yjha.lzmarathonsys.service.TbUserInfoService;


@Service("tbUserInfoService")
public class TbUserInfoServiceImpl extends ServiceImpl<TbUserInfoMapper, TbUserInfo> implements TbUserInfoService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<TbUserInfo> page = this.page(
                new Query<TbUserInfo>().getPage(params),
                new QueryWrapper<TbUserInfo>()
        );

        return new PageUtils(page);
    }

    @Override
    public R saveTbUserInfo(TbUserInfo tbUserInfo) {
        QueryWrapper<TbUserInfo> userInfoQueryWrapper = new QueryWrapper<TbUserInfo>().eq("tb_wxuuid", tbUserInfo.getTbWxuuid());
        TbUserInfo tbUserInfo1 = this.getOne(userInfoQueryWrapper);
        if (tbUserInfo1 != null) {
            return R.error(400,"用户已存在");
        }else{
            this.save(tbUserInfo);
            return R.ok();
        }
    }

}